package com.hospital.doctor.service;

import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.hospital.doctor.mapper.MedicalMapper;
import com.hospital.doctor.pojo.Medical;
import com.hospital.doctor.utils.JWTUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MedicalServiceImpl implements MedicalService {

    @Autowired
    private MedicalMapper medicalMapper;

    @Override
    public List<Medical> selectById(int id) {
        return medicalMapper.selectById(id);
    }

    @Override
    public int insertMedical(Medical medical) {
//        DecodedJWT verify = JWTUtils.
//                verify("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9." +
//                        "eyJuYW1lIjoi5LqM5aiDIiwiaWQiOiIxIiwiZXhwIjoxNjIxMzI0NzUyfQ.y75n_9jK60Stucvq2wkTFBJNlZE-R416oj8l6TqAzME");
//        Integer id = Integer.valueOf(verify.getClaim("id").asString());
//        medical.setdId(id);
        return medicalMapper.insertMedical(medical);
    }

    @Override
    public int updateMedical(Medical medical) {
        return medicalMapper.updateMedical(medical);
    }

    @Override
    public Medical selectBymId(int mId) {
        return medicalMapper.selectBymId(mId);
    }

    @Override
    public int stopMedical(int mId) {
        medicalMapper.insertStopTime(mId);
        return medicalMapper.stopMedical(mId);
    }

    @Override
    public int insertStopTime() {
        return 0;
    }


}
